Skip to content

feat(pinned events): persist the pinned events timeline#6085

Merged
bnjbvr merged 16 commits intomainfrom
bnjbvr/pinned-events-linked-chunk
Feb 5, 2026
Merged

feat(pinned events): persist the pinned events timeline#6085
bnjbvr merged 16 commits intomainfrom
bnjbvr/pinned-events-linked-chunk

Conversation

@bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jan 29, 2026

This brings some nice benefits:

  • reloading the previous list of pinned events from storage, which gives us…
  • …offline access for pinned events
  • better support for automatic redecryption of pinned events

Some important design points:

  • the pinned events linked chunk does include relations to pinned events, i.e. they're appended to the chunks as they show up from other sources (sync/backpaginations). This is different from the thread linked chunks, which don't, and should likely be uniformized towards that, in the future.
  • pinned events are first reloaded from storage, upon creation of the pinned event cache (lazily, when subscribing to pinned events for the first time); then, reloaded from network if needs be; then, updated over time, by a background task in the pinned event cache.
  • The task is never killed, at the moment. Ideally, it would be killed whenever there are no more listeners to the pinned events cache for this room. We should implement this in a soon future.
  • Lots of code duplication with the storage of linked chunks in the case of the room. To be deduplicated soon™.

Part of #5954.

@bnjbvr bnjbvr force-pushed the bnjbvr/pinned-events-linked-chunk branch from d6a6eed to 046adb4 Compare February 2, 2026 17:20
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 2, 2026

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing bnjbvr/pinned-events-linked-chunk (d277d9e) with main (9ad7cf9)

Open in CodSpeed

@bnjbvr bnjbvr force-pushed the bnjbvr/pinned-events-linked-chunk branch 5 times, most recently from fb23758 to 7f1f465 Compare February 4, 2026 18:24
@bnjbvr bnjbvr marked this pull request as ready for review February 4, 2026 18:24
@bnjbvr bnjbvr requested a review from a team as a code owner February 4, 2026 18:24
@bnjbvr bnjbvr requested review from stefanceriu and removed request for a team February 4, 2026 18:24
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 78.07933% with 105 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.81%. Comparing base (9ad7cf9) to head (d277d9e).
⚠️ Report is 16 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...s/matrix-sdk/src/event_cache/room/pinned_events.rs 74.79% 67 Missing and 25 partials ⚠️
crates/matrix-sdk/src/room/mod.rs 68.42% 5 Missing and 1 partial ⚠️
crates/matrix-sdk-common/src/serde_helpers.rs 80.00% 0 Missing and 3 partials ⚠️
crates/matrix-sdk/src/event_cache/room/mod.rs 89.65% 0 Missing and 3 partials ⚠️
...rates/matrix-sdk-ui/src/timeline/controller/mod.rs 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6085      +/-   ##
==========================================
- Coverage   89.88%   89.81%   -0.08%     
==========================================
  Files         363      363              
  Lines      100129   100479     +350     
  Branches   100129   100479     +350     
==========================================
+ Hits        90004    90246     +242     
- Misses       6621     6695      +74     
- Partials     3504     3538      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I left some comments. Most of them are minor so I'll approve ahead of time.

Comment on lines 266 to 267
// Only handle the remote aggregation for a non-live timeline, that's not the
// pinned events one (since this one handles its own remote events diffs).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this is needed for pinned events.

Copy link
Member Author

@bnjbvr bnjbvr Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I thought the live update task wouldn't be needed for the pinned events timeline, but that's actually unclear; it might be that the member profiles updates are still useful for such a timeline. Will defer this to a subsequent PR, and fix the comment in the meanwhile.

@bnjbvr
Copy link
Member Author

bnjbvr commented Feb 5, 2026

Clearing the other review requests, since Damir has reviewed this. Thanks!

@bnjbvr bnjbvr force-pushed the bnjbvr/pinned-events-linked-chunk branch from 7f1f465 to 595e6cc Compare February 5, 2026 14:18
@bnjbvr bnjbvr enabled auto-merge (rebase) February 5, 2026 14:22
@jmartinesp
Copy link
Contributor

We might want to delay merging this, I found an issue while testing it with EXA where after clearing the cache, some rooms with just 1 pinned event incorrectly displays several of them.

@bnjbvr bnjbvr disabled auto-merge February 5, 2026 14:30
…cache

There were two issues:

- first, `load_or_fetch_event_with_relations()` allowed to pass a
filter, but the filter wasn't taken into account when fetching relations
from the network. This would cause the initial load of pinned events to
also include thread responses, which we don't want.
- similarly, when adding related events from sync, we'd only look if an
event had a `m.relates_to` field; but it could be a thread response
being added in live.

The two issues are fixed similarly, by using a new `extract_relation`
serde helper that gives both the related_to event and the relation type.
That way, we can apply a manual filter in
`load_or_fetch_event_with_relations` after fetching relations from
network, and we can filter out live events based on the relation type.
@jmartinesp
Copy link
Contributor

The latest changes fix the previously found issue 🥳 !

@bnjbvr bnjbvr merged commit 80920e9 into main Feb 5, 2026
53 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/pinned-events-linked-chunk branch February 5, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UTDs on pinned messages are not retried after key is received

3 participants